import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const articleApi = {
  articleList: '/article/list',
  articleDetail: '/article/detail',
  articleAdd: '/article/add',
  articleUpdate: '/article/update',
  articleDelete: '/article/delete',
  articleClassify: '/articleClassify/listJson',
  articleEnabled: '/article/enabled',
} as const;

export const createArticle = (data: API.CreateArticleParams) => {
  return request({
    url: articleApi.articleAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const articleEnabled = (data: API.statusDTO) => {
  return request({
    url: articleApi.articleEnabled,
    method: RequestEnum.PUT,
    data,
  });
};
export const updateArticle = (data: API.UpdateArticleParams) => {
  return request({
    url: articleApi.articleUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteArticle = (params: { id: number }) => {
  return request({
    url: articleApi.articleDelete,
    method: RequestEnum.DELETE,
    params,
  });
};
export const articleClassify = () => {
  return request({
    url: articleApi.articleClassify,
    method: RequestEnum.GET,
  });
};
